package test;

import static org.junit.Assert.*;

import java.sql.SQLException;
import java.util.ArrayList;

import model.Room;
import model.RoomReservation;

import org.junit.Test;

import ctr.RRctr;
import db.DbConnection;

public class testReservation {

	@Test
	public void testDbConnection() {
		DbConnection con  = DbConnection.getInstance();
		assertNotNull(con);
		try {
			assertFalse(con.getDBcon().isClosed());
		} catch (SQLException e) {
			fail();
			e.printStackTrace();
		}
	}
	
	@Test
	public void testFindEmpty()
	{
		String checkIn = "20140519";
		String checkOut = "20140521";
		RRctr ctr = new RRctr();
		ArrayList<Room> list = ctr.findEmptyRooms(checkIn, checkOut);
		assertTrue(list.size()>0);
	}
	
	@Test
	public void testEmpty()
	{
		String checkIn = "20000101";
		String checOut = "30001231";
		RRctr ctr = new RRctr();
		ArrayList<Room> list = ctr.findEmptyRooms(checkIn, checOut);
		assertTrue(list.size()==0);
	}
	@Test
	public void makeReservation()
	{
		String status = "ikkefin";
		String checkIn = "20150620";
		String checkOut = "20150625";
		int guestId = 100;
		
		RRctr ctr = new RRctr();
		ArrayList<RoomReservation> list1 = ctr.findAllReservation();
		ctr.insertNew(status, checkIn, checkOut, guestId);
		ArrayList<RoomReservation> list2 = ctr.findAllReservation();
		assertTrue(list1.size()<list2.size());
	}
	

}
